<?php
namespace My\Model;

class ArticleCategoryModel extends CommonTreeModel {
	
	protected $_auto = array(
		array('content', 'getContent', self::MODEL_BOTH, 'callback'),
		array('tpl_config', 'getTplConfig', self::MODEL_BOTH, 'callback'),
	);
	
	// 栏目类型
	public $types = array(
			'page' => '单页图文栏目',
			'list' => '内容列表栏目',
			'url' => '外部链接栏目',
	);
	
	/**
	 * 单页内容
	 * @return boolean|mixed
	 */
	public function getContent() {
		if( !isset( $_REQUEST['content']) ) return false;
		$content = I("content", '', 'htmlspecialchars_decode');
		$pattern='/a .*?href=".*?tel:(\d+)".*?>/is';
		$replacement = 'a href="tel:${1}">';
		$content = preg_replace($pattern, $replacement, $content);
		return $content;
	}
	
	/**
	 * 获得模板配置
	 */
	public function getTplConfig() {
		if( !isset( $_REQUEST['tpl_config']) ) return false;
		$tpl_config = I("tpl_config");
		return serialize( $tpl_config );
	}
}